package com.fbinggun.playeraddattribute;

import com.fbinggun.fattribute.data.EntityData;
import com.fbinggun.fattribute.data.IUpDate;
import com.fbinggun.fattribute.status.Modifier;
import org.bukkit.entity.Player;

import java.sql.SQLException;

public class UpPlayerAddAttribute implements IUpDate {
    @Override
    public void up(EntityData entityData) {
        if(entityData.getEntity() instanceof Player){
            Player player = (Player) entityData.getEntity();
            try {
                PlayerData playerData =PlayerAddAttribute.plugin.getPlayerData(player);
                if(playerData.map!=null&&playerData.map.size()!=0) {
                    entityData.statusMap.addModifier(new Modifier("PlayerAddAttribute", PlayerAddAttribute.plugin, playerData.map));
                }
                } catch (SQLException e) {
                throw new RuntimeException(e);
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
